package homework.api.day03._cp;

import java.util.*;

public class CollectionOneDemo {
    public static void main(String[] args) {
        Collection<Integer> c = new ArrayList<>();
        c.add(1);
        c.add(2);
        c.add(1);
        c.add(4);
        c.add(5);
        c.add(2);
        System.out.println(c);

        boolean b = c.contains(1);
        System.out.println(b);

        c.remove(1);
        System.out.println(c);

        System.out.println("集合长度"+c.size());
        System.out.println("集合是否为空"+c.isEmpty());
        System.out.println("清空集合：");
        c.clear();

        System.out.println("遍历");
        c.add(1);
        c.add(2);
        c.add(1);
        c.add(4);
        c.add(5);
        c.add(2);
        System.out.println(c);

        Iterator<Integer> it = c.iterator();
        while(it.hasNext()){
            int n = it.next();
            System.out.print(n+" ");
        }
        System.out.println();

        for (int n : c){
            System.out.print(n+" ");
        }
        System.out.println();

        System.out.println("转换");
        Integer[] arr = c.toArray(new Integer[5]);
        System.out.println(Arrays.toString(arr));

        String[] array = new String[3];
        array[1] = "xxx";
        List<String> list =Arrays.asList(array);
        System.out.println(list);



    }
}
